package org.springcloud.wisdom.amusement.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.*;
import org.springcloud.wisdom.amusement.entity.Wall;

import java.util.List;

@Mapper
public interface WallDao extends BaseMapper {
    //发表信息
    @Insert("insert into wall(fatherid,name,toname,time,msg) VALUES(#{fatherid},#{name},#{toname},CURRENT_TIMESTAMP,#{msg})")
    public int addWallMsg(Wall wall);

    //举报信息
    @Update("update wall set report=report+1 where id=#{id}")
    public int reportWallMsg(Integer id);

    //审核信息
    @Update("update wall set ispass=1,report=0 where id=#{id}")
    public int judgeWallMsg(Integer id);
    //删除被举报超过十次的信息（假删除）
    @Update("update wall set overdelete=1 where id=#{id}")
    public int overDeleteMsg(Integer id);
    //恢复被举报超过十次的信息
    //这个审核方法，专门用于被举报过多的
    @Update("update wall set overdelete=0,ispass=1,report=0 where id=#{id}")
    public int recoverDeleteMsg(Integer id);

    //删除此消息并且删除所有子消息
    @Delete("delete from wall where id=#{id} or fatherid=#{id}")
    public int deleteWallMsg(Integer id);

    //获取所有墙上所有
    @Select("select  * from wall where overdelete!=1")
    public List<Wall> getAllWallMsg();
    //获取所有墙上所有被举报信息
    @Select("select  * from wall where report!=0")
    public List<Wall> getAllReportMsg();

    //获取被举报次数过多自动删除的信息
    @Select("select  * from wall where overdelete=1")
    public List<Wall> getDelWallMsg();
    //获取所有墙上所有
    @Select("select  * from wall where id=#{id}")
    public Wall getOneWall(Integer id);

}
